package hu.pixelesztergalyos.continuity;

import java.io.IOException;

// Realizing the Key in Java
public class Key extends MosaicElement implements Collideable, Drawable {

	// Storing if the character has acquired the key already or not
	private boolean isAcquired;

	// Constructor
	public Key() {
		super();
	}

	// Construct in the given origin
	public Key(float x, float y) {
		super(x, y);
	}

	// return with the value of isAcquired
	public boolean getIsAcquired() {
		return isAcquired;
	}

	// set the isAcquired flag to the value given in the parameter
	public void setIsAcquired(boolean isAcquired) {
		this.isAcquired = isAcquired;
	}

	public void draw() {
		// empty
	}

	// The Key has collided with a Character
	public void hitBy(Character character) throws IOException {
		isAcquired = true;
		character.hitBy(this);
		if (isAcquired == false) {
			isAcquired = true;
		}

	}

	// The Key has collided with a BuildingBlock
	// never occurs
	public void hitBy(BuildingBlock buildingBlock) {
		// empty
	}

	// The Key has collided with the Gate
	// never occurs
	public void hitBy(Gate gate) {
		// empty
	}

	// The Key has collided with the Key
	// never occurs
	public void hitBy(Key key) {
		// empty
	}

	// The Key has collided with a TransitionBlock
	// never occurs
	public void hitBy(TransitionBlock transitionBlock) {
		// empty
	}

	// returns the visual represent in the XML
	public char getType() {
		return 'k';
	}
}
